package com.javalab._7thread._3Lock._1Synchronized;

public class Test {
    public static void main(String[] args) throws InterruptedException {
        // 创建公共数据
        CommonData counter = new CommonData();
        // 创建2个线程
        MyRunnable myRunnable = new MyRunnable(counter);
        Thread thread1 = new Thread(myRunnable);
        Thread thread2 = new Thread(myRunnable);
        // 启动两个线程
        thread1.start();
        thread2.start();

        // 主线程等待2个线程处理完成
        thread1.join();
        thread2.join();
        // 打印结果，看是否符合期望值
        System.out.println(counter.getValue());
    }
}
